package day3.com.test;

import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class PhoneRegex {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//定义要查找的字符串
		String phone = "18613903033";
		//1 定义规则
		String regex = "(^0{0,1}1[0-9]{10}$)";
		//2 创建正则表达式对象 
		Pattern pt = Pattern.compile(regex);
		//3 使用比较器，进行比较
		Matcher mc = pt.matcher(phone);
		//4 判断是否比较成功
        //System.out.println(mc.find());
         if(mc.find()){
              
           regex = "(^0{0,1}1(56|86)[0-9]{8}$)";
          
           mc =  Pattern.compile(regex).matcher(phone);
           System.out.println(mc.find());
         }
//		while(mc.lookingAt()){
//			//得到更详细的比较结果
//			int start = mc.start();
//			int end = mc.end();
//			System.out.println("start index :"+start+",end index:"+end);
//			
//		}
		
		/*boolean b = url.matches(regex);
		System.out.println(b);*/
		
	}

}
